package com.sl.proxy.core.coder;

import cn.hutool.core.collection.CollUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpMessage;
import io.netty.handler.codec.http.HttpRequestEncoder;
import lombok.SneakyThrows;
import org.apache.commons.compress.utils.Lists;

import java.util.List;

public class CustomHttpRequestEncoder extends HttpRequestEncoder {

    @SneakyThrows
    public ByteBuf encode(ChannelHandlerContext ctx, HttpMessage message) {
        List<Object> objects = Lists.newArrayList();
        super.encode(ctx,message,objects);
        return (ByteBuf) CollUtil.get(objects,0);
    }
}
